clear
set more off
set mem 1g
# delimit ;
/*****************************************************************************************************************;
**This dofile starts from raw DHS data (DHS2004/BDKR4JDT/BDKR4JFL.DTA) and generates expandedDHSGPS_Mergedhh1999;

other pre-generated datasets this dofile also uses:
collapsedGPS1999
*****************************************************************************************************************/;

*****************************************************************************************************************;
*Paths;
*****************************************************************************************************************;

*access files in subdirectory generated by data creating dofiles;
local indataset "rawdta/DHS1999/BDKR41DT/BDKR41FL.DTA";

local outdataset "dtafiles/expandedDHSGPS_Mergedhh1999";

*****************************************************************************************************************;
*Main;
*****************************************************************************************************************;

use "`indataset'";

ren v001 dhsid99;
gen year=1999;

**HW: renames household variables**;
*breastfeeding;
ren v409 plainwater;
ren v411a babyformula;
ren v413 otherliq;
ren v409a sugarwater;
ren v412 cowgoat;
ren m4 durationbreast;
ren m5 monthsbreast;
ren hw1 childage;
ren b2 childbyear;

ren hw5 htasd;
ren hw11 wthtsd;

ren v113 watersource;
ren h11 diarrhea;

**HW: merge assigns well characteristics from cluster to household observation**;
merge m:1 dhsid99 using "dtafiles/collapsedGPS1999.dta";
drop _m;

save "`outdataset'",replace;


